package com.itheima.io1.mytest;

import java.io.*;
import java.nio.charset.Charset;

/**
 * @author zhangbaiyan
 * @date 2024-09-21 17:44
 * @description: 转换流基本用法
 * @version: 1.0
 */
public class test7 {
    public static void main(String[] args) throws IOException {
//        InputStreamReader isr = new InputStreamReader(new FileInputStream("gbk.txt"), "GBK");
//        int ch;
//        while ((ch = isr.read()) != -1) {
//            System.out.print((char) ch);
//        }
//        isr.close();

        FileReader fr = new FileReader("gbk.txt", Charset.forName("GBK"));
        //读取数据
        int ch;
        while ((ch = fr.read()) != -1) {
            System.out.print((char)ch);
        }
        //释放资源
        fr.close();
    }
}
